import log from '@dfeidao/atom-nodejs/logger/log';
import logout from '@dfeidao/atom-nodejs/msg/user-logout';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '././config';

interface Message {
	cookie: {
		uk: string;
		[key: string]: string
	};
	urls: {
		base: string;
		origin: string;
		url: string;
	};
	query: {};
	params: {};
	headers: { cookie: string };
	usercode: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin');
	// todo
	const res = await logout(action_id, session_id, systemid, message.usercode);
	return {
		data: res,
		cookie: {
			sessionid: ''
		}
	};
}
